package de.fuberlin.inf.alp3.ue07;

import java.util.List;

import de.fuberlin.inf.alp3.utils.ConsoleInput;
import de.fuberlin.inf.alp3.utils.TestData;

public class TreeSetTest {
    public static void main(String[] args) {
        TreeSet<String> t = new TreeSet<String>();
        System.out.println("A new TreeSet<String> object has been created.");
        int userInput = -1;
        while (true) {
            System.out.println("  1. Add a String to the TreeSet");
            System.out.println("  2. Add countries in random order");
            System.out.println("  3. Show all elements of the TreeSet in order");
            System.out.println("  4. Get elements between...");
            System.out.println("\n  0. Exit application");
            userInput = ConsoleInput.readInt("Your choice?", "Not a number!");
            switch (userInput) {
            case 0:
                System.out.println("Bye...");
                System.exit(0);
            case 1:
                t.add(ConsoleInput.readString("Enter a string!"));
                break;
            case 2:
                List<String> countries = TestData.getCountries(true);
                for (String s : countries) t.add(s);
                break;
            case 3:
                for (String item : t)
                    System.out.println(item + " ");
                break;
            case 4:
                List<String> l = t.list(
                        ConsoleInput.readString("Lower border?"),
                        ConsoleInput.readString("Upper border?"));
                for (String item : l)
                    System.out.println(item + " ");
                break;
            default:
                System.out.println("Please choose from available options.");
            }
        }
    }
}
